
#include <iostream>
#include "scanner_test.h"
#include "grammar_test.h"
#include "parser_test.h"


using namespace tenacitas::interpreter::test;



int main ( int argc, char ** argv ) {

    if ( argc != 2 ) {
        std::cout << "Syntax : " << argv [0] << " <file-name> \n"
                  << "Where <file-name> is the name of the file that "
                  << "contains the text to be lexicaly analysed"
                  << std::endl;
    }
    else {
	try {
	    test_scanner l_test_scanner;
	    if ( !l_test_scanner.exec ( ) ) {
		std::cout << "ERROR on 'test_lexical' " ;
	    }
	    else {
		std::cout << "SUCCESS for 'test_lexical' ";
	    }
	    std::cout << std::endl << std::endl;
	    

	    test_grammar_1 l_test_grammar_1;
	    if ( !l_test_grammar_1.exec (  ) ) {
		std::cout << "ERROR on 'test_grammar_1' " ;
	    }
	    else {
		std::cout << "SUCCESS for 'test_grammar_1' ";
	    }
	    std::cout << std::endl << std::endl;

	    
            test_parser_1 l_test_parser_1;
	    if ( !l_test_parser_1.exec ( argv[1] ) ) {
		std::cout << "ERROR on 'test_parser_1' " ;
	    }
	    else {
		std::cout << "SUCCESS for 'test_parser_1' ";
	    }
	    std::cout << std::endl << std::endl;	    
	}
	catch ( interpreter::fault & e ) {
	    cout << "Error: " << e.what ( ) << endl;
	}
	catch ( tenacitas::number::fault & e ) {
	    cout << "FAULT: " << e.what ( ) ;
	}

        std::cout << std::endl;
    }

    return 0;
}

